<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0,
           maximum-scale=1.0, minimum-scale=1.0"/>
    <title>angular中使用jquery</title>
</head>
<body>
<div ng-app="myApp">
    <!--判断-->
    <div ng-controller="choiceController">
        {{name }}
        {{array}}
        {{age}}
        <!--{{qw}}-->
        <!--{{str}}-->

        <div id="obj1"></div>
    </div>

    <!--这个地方引用了其他的js -->
    <div ng-controller="frist">
       {{aaa}}
    </div>

</div>
</body>
<script src="js/jquery.min.js"></script>
<script src="js/angular.js"></script>
<!--此处需要做引用,插件的方式也是通过这个方式来引用的-->
<script src="js/main.js"></script>
<script type="text/javascript">
    // 获取angular对象通过对象，操作controller
    var app= angular.module("myApp",["myapp2"]);
    //将数据中的对象通过angular编写比较赋值给$scope.对象 然后获取这个对象的值;
    app.controller('choiceController', function ($scope) {
        $scope.name="zhangsan";
        $scope.arr=[2,3,4,5];
        $scope.array=angular.isArray($scope.arr);

        $scope.age=angular.uppercase($scope.name);

        $scope.a="111";
        $scope.b=111;
        $scope.qw=angular.equals($scope.a,$scope.b);

        //此处是指aa要继承bb中的值,注意aa与bb中的值必须是json对象
        $scope.aa={name:"aaa"};
        $scope.bb={age:23};
        $scope.c= angular.extend($scope.aa,$scope.bb);
//        console.log($scope.aa);

        var json={name:"zhangsan",age:25};
        $scope.str=angular.toJson(json);
        $scope.str=angular.toJson(json,true);

        //将字符串转成json,注意:此处声明的字符串全部需要加引号;包含{}中的对象,否则会报错
        var jsonStr='{"name":"zhangsan","age":"25"}';
        $scope.json1=angular.fromJson(jsonStr);

        //copy是将aa数据复制给bb
        $scope.qq={name:"aaa"};
        $scope.ww={age:23};
        $scope.xx= angular.copy($scope.qq,$scope.ww);
        console.log($scope.qq);
        console.log($scope.ww);

        //遍历json,如果有results就可以添加到数组中去
        var results=[];
        var jsons={"name":"zhangsan","age":"24","sex":"男"};
        angular.forEach(jsons, function (value,key) {
            // 将数据推到数据results中去;
            this.push(key+"---"+value);
        },results);
        console.log(results);

        //绑定数据为上下文,可以传递值;
        var self={"name":"zhsans"};
        var ff=angular.bind(self, function (age) {
            $scope.info=this.name+"---"+age;
            console.log($scope.info);
        });
        ff(30);

        $("#obj1").html('<span>你现在还好吗</span>');
    })

</script>
</html>